package com.ruoyi.equip.vert.service.impl;

import com.ruoyi.common.utils.net.HexUtil;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.equip.vert.config.TcpServerVerticle;
import com.ruoyi.equip.vert.domain.TcpAnsEntity;
import com.ruoyi.equip.vert.domain.TcpParserEntity;
import com.ruoyi.equip.vert.service.TransferStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import static com.ruoyi.equip.vert.TcpReaderConstant.*;

@Slf4j
@Service
public class ConfigModeTransfer implements TransferStrategy {
    //IEquipTagService tagService = SpringUtils.getBean(IEquipTagService.class);
    TcpServerVerticle tcpServerVerticle = SpringUtils.getBean(TcpServerVerticle.class);

    @Override
    public void transfer(TcpParserEntity tcpParserEntity) {
        // 组装返回数据
        TcpAnsEntity tcpAns = new TcpAnsEntity();
        tcpAns.setOptType(ANS_CONFIG_MODE);
        tcpAns.setReaderId(tcpParserEntity.getReaderId());
        tcpAns.setParam(HexUtil.hexListToStr(tcpParserEntity.getParam()));
        tcpAns.setCrc("0a");
        tcpServerVerticle.sendMsg(tcpParserEntity.getHandlerID(),tcpAns.toString());

    }





}
